package diamond.day02;

/**
 * 例子:创建三个窗口卖票，总票数为100张
 */
class Windows extends Thread{
    private static int ticket = 100;
    @Override
    public void run() {
        while (true){
            if(ticket>0){
                System.out.println(getName()+"：卖票，票号为:"+ticket);
                ticket--;
            }
        }
    }
}

public class WindowsTest {
    public static void main(String[] args) {
        Windows w1 = new Windows();
        w1.setName("线程一");
        Windows w2 = new Windows();
        w2.setName("线程二");
        Windows w3 = new Windows();
        w3.setName("线程三");
        w1.start();
        w2.start();
        w3.start();
    }
}
